package com.mayuhao.professionmanage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mayuhao.professionmanage.entity.CssDepVO;
import com.mayuhao.professionmanage.entity.CssProfession;
import com.mayuhao.professionmanage.service.ICssProfessionService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 马宇豪
 * @since 2022-10-24
 */
@RestController
//@RequestMapping("/css-profession")
public class CssProfessionController {
    @Resource
    private ICssProfessionService professionService;

    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName saveDepartment
     * @params [profession]
     * @paramType [com.mayuhao.professionmanage.entity.CssProfession]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:18
     * @email 1757442521@qq.com
     **/
    @PostMapping("/save")
    public boolean saveDepartment(@RequestBody CssProfession profession) {

        return professionService.save(profession);
    }

    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName deleteDepartment
     * @params [id]
     * @paramType [java.lang.Integer]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:19
     * @email 1757442521@qq.com
     **/
    @DeleteMapping("/delsingle/{id}")
    public boolean deleteDepartment(@PathVariable String id) {
        return professionService.removeById(id);
    }

    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName deleteDepartment
     * @params [ids]
     * @paramType [java.util.List]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:19
     * @email 1757442521@qq.com
     **/
    @DeleteMapping("/delbatch/{ids}")
    public boolean deleteDepartment(@PathVariable List ids) {
        return professionService.removeBatchByIds(ids);
    }


    /**
     * @return boolean
     * @description 请修改方法描述
     * @methodName updateDepartment
     * @params [profession]
     * @paramType [com.mayuhao.professionmanage.entity.CssProfession]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:20
     * @email 1757442521@qq.com
     **/
    @PutMapping("/update")
    public boolean updateDepartment(@RequestBody CssProfession profession) {
        return professionService.updateById(profession);
    }

    /**
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.mayuhao.professionmanage.entity.CssProfession>
     * @description 请修改方法描述
     * @methodName findPage
     * @params [pageNum, pageSize, searchId, searchName]
     * @paramType [java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:20
     * @email 1757442521@qq.com
     **/
    @GetMapping("/findpage")
    public Page<CssDepVO> findPage(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "7") Integer pageSize, @RequestParam(defaultValue = "") String searchId, @RequestParam(defaultValue = "") String searchName) {
        return professionService.findPage(pageNum, pageSize, searchId, searchName);
    }

    /**
     * @return java.util.List<java.lang.String>
     * @description 请修改方法描述
     * @methodName findDep
     * @params []
     * @paramType []
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 7:38
     * @email 1757442521@qq.com
     **/
    @GetMapping("/finddep")
    public String findDep() {
        return professionService.findDep();

    }

    /**
     * @return void
     * @description 请修改方法描述
     * @methodName export
     * @params [response]
     * @paramType [javax.servlet.http.HttpServletResponse]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:20
     * @email 1757442521@qq.com
     **/
    @GetMapping("/export")
    public void export(HttpServletResponse response) throws IOException {

        professionService.export(response);
    }

    /**
     * @return void
     * @description 请修改方法描述
     * @methodName imp
     * @params [file]
     * @paramType [org.springframework.web.multipart.MultipartFile]
     * @author 马宇豪
     * @date 2022/10/24 0024 下午 1:26
     * @email 1757442521@qq.com
     **/
    @PostMapping("/import")
    public void imp(MultipartFile file) throws Exception {

        professionService.imp(file);
    }

}
